

export default class Record {
  static _ins: Record
  static get instance() {
    return Record._ins || new Record
  }
  constructor() {
    Record._ins = this
  }

  init() {

    /** google */
    window.dataLayer = window.dataLayer || [];

    (function (d, s, id) {
      var js: HTMLScriptElement, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) {
        return;
      }
      js = <HTMLScriptElement>d.createElement(s);
      js.id = id;
      js.async = true
      js.src = "https://www.googletagmanager.com/gtag/js?id=UA-102180151-40";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'google-jssdk'));

    this.gtag('js', new Date());
    this.gtag('config', 'UA-102180151-40');

  }

  gtag(...args) {
    window.dataLayer.push(arguments);
  }

  /**
   * 老玩家礼包领取成功 打点
   */
  point1() {
    this.gtag('event', 'oldplayer', {
      'event_category': 'oldplayer_category',
      'event_label': 'oldplayer_label'
    })
  }

  /**
   * 第一天登录礼包领取成功
   */
  point2() {
    this.gtag('event', 'firstday', {
      'event_category': 'firstday_category',
      'event_label': 'firstday_label'
    });
  }

}